/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.autosalon.ui.customer.action;

import com.autosalon.ui.customer.Customer;
import com.autosalon.ui.customer.state.CustomerStateHolder;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Form;
import com.vaadin.ui.Label;
import com.vaadin.ui.TextField;

/**
 *
 * @author Kubík
 */
public class AddAdressAction extends AbstractCustomerAction implements Button.ClickListener {

    public AddAdressAction(Customer customer) {
        super(customer);
    }

    @Override
    public void buttonClick(ClickEvent event) {
        int countOfAdress = customer.getCountOfAdress() + 1;
        customer.setCountOfAdress(countOfAdress);

        Form adress = new Form();
        adress.getLayout().addComponent(new Label("Aresa " + countOfAdress));
        adress.getLayout().addComponent(new TextField("Stát"));
        adress.getLayout().addComponent(new TextField("Město"));
        adress.getLayout().addComponent(new TextField("Ulice"));
        adress.getLayout().addComponent(new TextField("Č. popisné"));
        adress.getLayout().addComponent(new TextField("Č. orientační"));
        adress.getLayout().addComponent(new TextField("PSČ"));
        customer.getNewAdress().add(adress);
        customer.addComponent();
        int id;
        try {
            id = customer.getSwitcher().getMainWindow().getZakaznik().getRole().getId().intValue();
        } catch (NullPointerException e) {
            id = 1;
        }
        CustomerStateHolder.setState(CustomerStateHolder.ADD_ADRESS_STATE, id, customer);

    }
}
